using System.Collections.Generic;
using SmartBoard.Core.Converters;
using System;
using SmartBoard.Core.Serialization;

namespace SmartBoard.Background.Serialization
{
    internal class SerializationStrategyProvider : ISerializationStrategyProvider
    {
        #region Private Fields
        private readonly IDictionary<StrategyVersion, ISerializationStrategy> _strategyCollection;
        #endregion

        #region Ctor
        public SerializationStrategyProvider()
        {
            _strategyCollection = new Dictionary<StrategyVersion, ISerializationStrategy>();
            _strategyCollection[StrategyVersion.V10] = new V10SerializationStrategy();
            _strategyCollection[StrategyVersion.V11] = new V11SerializationStrategy();
        }
        #endregion

        public ISerializationStrategy Strategy(byte strategyTolookFor)
        {
            var objformat = EnumHelper.GetEnumValue(strategyTolookFor, typeof (StrategyVersion));
            if (objformat == null)
                throw new ArgumentException("Strange Serialization Format for Background element", strategyTolookFor.ToString());

            return _strategyCollection[(StrategyVersion) objformat];
        }
    }
}